package dao;

import entity.Subject;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import untils.DruidUtil;

import java.sql.SQLException;

/**
 * @Author:SA
 * @DATA:DATA
 */


public class SubjectDaoImpl implements SubjectDao{
    @Override
    public Subject selectByName(String subname) {
        QueryRunner queryRunner = new QueryRunner(DruidUtil.getDataSource());
        String sql="select id,subname from subject where subname = ?";
        try {
            Subject subject = queryRunner.query(sql, new BeanHandler<>(Subject.class),subname);
            return  subject;

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }


        return null;
    }
}
